package ar.com.sudoku.rules;

import java.util.ArrayList;
import java.util.List;

import ar.com.sudoku.model.SudokuNumber;
import ar.com.sudoku.model.Grid;

public class ColumnRule implements Rule {

	@Override
	public boolean apply(Grid grid) {
		List<SudokuNumber> column = new ArrayList<SudokuNumber>();
		for (SudokuNumber y : SudokuNumber.values()) {
			for (SudokuNumber x : SudokuNumber.values()) {
				if (grid.get(x,y) == null) {
					continue;
				}
				if (column.contains(grid.get(x,y))) {
					return false;
				} else  {
					column.add(grid.get(x,y));
				}
			}
			column.clear();
		}
		return true;
	}

}
